﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class System_ParamSet : System.Web.UI.Page
{
    Function f = new Function();
    ZSql zs = new ZSql();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblPath.Text = f.getModuleidAdd(Request.QueryString["moduid"]);
            initData();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int siteState = 0;
        int isRightKey = 0;
        int isRightKey1 = 0;

        if (RadioOpen.Checked)
        {
            siteState = 1;
        }
        if (RadioPrice.Checked)
        {
            isRightKey = 1;
        }
        if (Radiorestprice1.Checked)
        {
            isRightKey1 = 1;
        }

        zs.Open("select * from CS_Param");
        if (zs.m_table.Rows.Count < 1)
        {
            zs.Open("insert into CS_Param(SiteState,SiteClose,IsPrice,IsrestPrice,CreateDate,SiteName,SiteAddress,lxAddress,CopyRight,recode)values(" + siteState + ",'" + Common.FormatParameter(txtCont.Text) + "'," + isRightKey + "," + isRightKey1 + ",'" + Common.FormatParameter(txtCarentDate.Text) + "','" + Common.FormatParameter(txtSiteName.Text) + "','" + Common.FormatParameter(txtSiteAddress.Text) + "','" + Common.FormatParameter(txtLXAddress.Text) + "','" + Common.FormatParameter(txtsuoyou.Text) + "','" + Common.FormatParameter(txtANhao.Text) + "')");
           
        }
        else
        {
            string sql = "update CS_Param set siteState=" + siteState + ",SiteClose='" + Common.FormatParameter(txtCont.Text) + "',IsPrice=" + isRightKey + ",IsrestPrice=" + isRightKey1 + ",CreateDate='" + Common.FormatParameter(txtCarentDate.Text) + "',siteName='" + Common.FormatParameter(txtSiteName.Text) + "',SiteAddress='" + Common.FormatParameter(txtSiteAddress.Text) + "',lxAddress='" + Common.FormatParameter(txtLXAddress.Text) + "',CopyRight='" + Common.FormatParameter(txtsuoyou.Text) + "',recode='" + Common.FormatParameter(txtANhao.Text) + "'";

            zs.Open(sql);
        }
      

        

        zs.Close();
    }
    private void initData()
    {
        zs.Open("select * from CS_Param");
        if (zs.m_table.Rows.Count > 0)
        {


            if (zs.m_table.Rows[0]["siteState"].ToString() == "1")
            {
                RadioOpen.Checked = true;
            }
            else
            {
                RadioClose.Checked = true;
            }

            if (zs.m_table.Rows[0]["IsPrice"].ToString() == "1")
            {
                RadioPrice.Checked = true;
            }
            else
            {
                RadioPric.Checked = true;
            }
            if (zs.m_table.Rows[0]["IsrestPrice"].ToString() == "1")
            {
                Radiorestprice1.Checked = true;
            }
            else
            {
                Radiorestprice2.Checked = true;
            }
            txtCont.Text = zs.m_table.Rows[0]["SiteClose"].ToString();

            txtsuoyou.Text = zs.m_table.Rows[0]["CopyRight"].ToString();
            txtANhao.Text = zs.m_table.Rows[0]["Recode"].ToString();

            txtCarentDate.Text = zs.m_table.Rows[0]["CreateDate"].ToString();
            txtSiteName.Text = zs.m_table.Rows[0]["siteName"].ToString();
            txtSiteAddress.Text = zs.m_table.Rows[0]["SiteAddress"].ToString();
            txtLXAddress.Text = zs.m_table.Rows[0]["lxAddress"].ToString();
           
        }
    }
}
